package com.huaxia.day14.Singleton;

public class SafeSingleton {

    private volatile static SafeSingleton singleton;

    private SafeSingleton() {
    }

    public static SafeSingleton getSingleton() {
        if (singleton == null) {
            synchronized (Singleton.class) {// 锁
                if (singleton == null) {
                    singleton = new SafeSingleton();
                }
            }
        }
        return singleton;
    }


    public static synchronized SafeSingleton getSingle() {
        if (singleton == null) {
            singleton = new SafeSingleton();
        }
        return singleton;
    }
}
